// src/App.tsx
import  { FC } from 'react';

import BaseLayout from '@/layout/index'
import Login from '@/views/login/Index'

import { Routes, Route, Navigate } from 'react-router-dom'


import './App.css'
import { useAppSeletor } from './store/hooks';

import store2 from 'store2'

interface IAppProps {
}

const App: FC<IAppProps> = (props) => {
  const adminname = useAppSeletor(state=>state.admin.adminname)
  const redirect = store2.session.get('redirect')
  // const loginState = useAppSeletor(state => state.admin.adminname)
  return (
    <Routes>
      <Route path="/login" element = { adminname ? <Navigate to={redirect?redirect:"/"}/> :<Login /> } />
      <Route path='/*' element = { adminname ? <BaseLayout /> : <Navigate to="/login"/> } />
      {/* <Index /> */}
    </Routes>
  )
}

export default App